package com.licheng.mapper;

import com.licheng.pojo.Student;
import com.licheng.pojo.StudentPageQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {
    /**
     * 条件分页查询学生
     * @param spq
     * @return
     */
    List<Student> selctStudentPage(StudentPageQuery spq);

    /**
     * 根据id批量删除学生
     * @param ids
     */
    void deleteStudentById(List<Integer> ids);

    /**
     * 添加学生
     * @param student
     */
    void insertStudent(Student student);

    /**
     * 修改学生
     * @param id
     * @return
     */
    @Select("select * from student where id = #{id}")
    Student selectStudentById(Integer id);

    /**
     * 修改学生
     * @param student
     */
    void updateStudent(Student student);

    /**
     * 违纪
     * @param id
     * @param score
     */
    @Update("update student set violation_score = violation_score + #{score}," +
            "violation_count = violation_count + 1 where id = #{id}")
    void violationScoreAndCount(Integer id, Integer score);

    /**
     * 统计学生学历情况
     * @return
     */
    List<Map> studentDegreeData();


}
